import Vue from 'vue'
import Router from 'vue-router'
import Layout from '@/views/layout/Layout'

Vue.use(Router)

export const constantRouterMap = [
  {
    path: '/login',
    component: () => import('@/views/login/index')
  }
]

export const asyncRouterMap = [
  {
    path: '/',
    component: Layout,
    redirect: '/index',
    children: [{
      path: '/index',
      component: () => import('@/views/homepage/index'),
      name: 'homepage',
      meta: {
        title: 'homepage',
        icon: 'ico1',
        roles: ['admin', 'province', 'city', 'area', 'school']
      }
    }]
  },
  {
    path: '/school-overview',
    component: Layout,
    redirect: '/school-overview/index',
    children: [{
      path: '/school-overview/index/:schoolId',
      component: () => import('@/views/school-overview/index'),
      name: 'school-overview',
      meta: {
        title: 'school-overview',
        icon: 'ico2',
        roles: ['admin', 'province', 'city', 'area', 'school']
      }
    }]
  },
  {
    path: '/experimental-area-school-management',
    component: Layout,
    meta: {
      title: 'experimental-area-school-management',
      icon: 'ico3',
      roles: ['admin', 'area', 'school']
    },
    children: [
      {
        path: '/experimental-area-school-management/district-management',
        component: () => import('@/views/experimental-area-school-management/district-management'),
        name: 'district-management',
        meta: {
          title: 'district-management',
          roles: ['admin']
        }
      },
      {
        path: '/experimental-area-school-management/school-management',
        component: () => import('@/views/experimental-area-school-management/school-management'),
        name: 'school-management',
        meta: {
          title: 'school-management',
          roles: ['admin', 'area']
        }
      },
      {
        path: '/experimental-area-school-management/student-management',
        component: () => import('@/views/experimental-area-school-management/student-management'),
        name: 'student-management',
        meta: {
          title: 'student-management',
          roles: ['admin', 'area', 'school']
        }
      },
      {
        path: '/experimental-area-school-management/district-school-import',
        component: () => import('@/views/experimental-area-school-management/district-school-import'),
        name: 'district-school-import',
        meta: {
          title: 'district-school-import',
          roles: ['admin']
        }
      }
    ]
  },
  {
    path: '/physique-report-download',
    component: Layout,
    meta: {
      title: 'physique-report-download',
      icon: 'ico4',
      roles: ['admin', 'area']
    },
    children: [
      {
        path: '/physique-report-download/download-package',
        component: () => import('@/views/physique-report-download/download-package'),
        name: 'download-package',
        meta: {
          title: 'download-package',
          roles: ['admin', 'area']
        }
      },
      {
        path: '/physique-report-download/sub-download',
        component: () => import('@/views/physique-report-download/sub-download'),
        name: 'sub-download',
        meta: {
          title: 'sub-download',
          roles: ['admin', 'area']
        }
      }
    ]
  },
  {
    path: '/data-visualization',
    component: Layout,
    redirect: '/school-overview/index',
    children: [
      {
        path: '/data-visualization/index',
        component: () => import('@/views/data-visualization'),
        name: 'multidimensional-data',
        meta: {
          title: 'data-visualization',
          icon: 'ico5',
          roles: ['admin', 'province', 'city', 'area', 'school']
        }
      }
    ]
  },
  {
    path: '/physical-data-management',
    component: Layout,
    meta: {
      title: 'physical-data-management',
      icon: 'ico6',
      roles: ['admin']
    },
    children: [
      {
        path: '/physical-data-management/data-upload',
        component: () => import('@/views/physical-data-management/data-upload'),
        name: 'data-upload',
        meta: {
          title: 'data-upload',
          roles: ['admin']
        }
      },
      {
        path: '/physical-data-management/data-management',
        component: () => import('@/views/physical-data-management/data-management'),
        name: 'data-management',
        meta: {
          title: 'data-management',
          roles: ['admin']
        }
      }
    ]
  },
  {
    path: '/label-management',
    component: Layout,
    meta: {
      title: 'label-management',
      icon: 'ico7',
      roles: ['admin']
    },
    children: [
      {
        path: '/label-management/index',
        component: () => import('@/views/label-management/label-management'),
        name: 'label-management',
        meta: {
          title: 'label-management',
          roles: ['admin']
        }
      },
      {
        path: '/label-management/tag',
        component: () => import('@/views/label-management/tag'),
        name: 'tag',
        meta: {
          title: 'tag',
          roles: ['admin']
        }
      },
      {
        path: '/label-management/template-import',
        component: () => import('@/views/label-management/template-import'),
        name: 'template-import',
        meta: {
          title: 'template-import',
          roles: ['admin']
        }
      }
    ]
  },
  {
    path: '/authority-management',
    component: Layout,
    redirect: '/authority-management/index',
    children: [{
      path: '/authority-management/index',
      component: () => import('@/views/authority-management/index'),
      name: 'authority-management',
      meta: {
        title: 'authority-management',
        icon: 'ico8',
        roles: ['admin']
      }
    }]
  },
  {
    path: '/app-management',
    component: Layout,
    redirect: '/app-management/index',
    children: [{
      path: '/app-management/index',
      component: () => import('@/views/app-management/index'),
      name: 'app-management',
      meta: {
        title: 'app-management',
        icon: 'ico9',
        roles: ['admin']
      }
    }]
  }]
export default new Router({
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
